<?php

namespace App\Models\FeishuCallingCard;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class FeishuCallingCardInvitationLog extends BaseModel
{
    use HasFactory;

    protected $table = 'feishu_calling_cards_invitation_logs';

    protected $fillable = [
        'openid',
        'invitorId',
    ];

    public static function boot()
    {
        parent::boot();
        static::saving(function ($model) {
            if (is_numeric($model->invitorId) || 'u' === mb_substr($model->invitorId, 0, 1)) {
                // 没问题
            } else {
                $model->invitorId = 1;
            }
        });
    }
}
